package cn.fufeiii.bt.demo.knife4j;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author FuFei
 */
@Configuration
public class Knife4jConfig {


    @Bean
    public OpenAPI openAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("DEMO-BOOT API")
                        .description("XXX服务")
                        .version("v1.0.0")
                        .contact(new Contact().name("FuFei"))
                        .license(new License().name("Apache 2.0"))
                );
    }

    @Bean
    public GroupedOpenApi g1() {
        return GroupedOpenApi.builder()
                .group("分组一")
                .pathsToMatch("/base/**")
                .build();
    }

    @Bean
    public GroupedOpenApi g2() {
        return GroupedOpenApi.builder()
                .group("分组二")
                .pathsToMatch("/knife4j/**")
                .build();
    }

    @Bean
    public GroupedOpenApi g3() {
        return GroupedOpenApi.builder()
                .group("分组三")
                .pathsToExclude("/base/**", "/knife4j/**")
                .build();
    }
}
